package c.a.a.z.b;

import android.annotation.TargetApi;
import android.graphics.Matrix;
import android.graphics.Path;
import android.graphics.Path.Op;
import c.a.a.b0.k.h;
import c.a.a.z.c.o;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

@TargetApi(19)
/* compiled from: MergePathsContent */
public class l implements m, j {
    public final Path a = new Path();
    public final Path b = new Path();
    public final Path c = new Path();
    public final List<m> d = new ArrayList();
    public final h e;

    public l(h hVar) {
        this.e = hVar;
    }

    @TargetApi(19)
    public final void c(Op op) {
        this.b.reset();
        this.a.reset();
        for (int size = this.d.size() - 1; size >= 1; size--) {
            m mVar = (m) this.d.get(size);
            if (mVar instanceof d) {
                d dVar = (d) mVar;
                List e = dVar.e();
                for (int size2 = e.size() - 1; size2 >= 0; size2--) {
                    Matrix e2;
                    Path h = ((m) e.get(size2)).h();
                    o oVar = dVar.k;
                    if (oVar != null) {
                        e2 = oVar.e();
                    } else {
                        dVar.c.reset();
                        e2 = dVar.c;
                    }
                    h.transform(e2);
                    this.b.addPath(h);
                }
            } else {
                this.b.addPath(mVar.h());
            }
        }
        int i = 0;
        m mVar2 = (m) this.d.get(0);
        if (mVar2 instanceof d) {
            d dVar2 = (d) mVar2;
            List e3 = dVar2.e();
            while (i < e3.size()) {
                Matrix e4;
                Path h2 = ((m) e3.get(i)).h();
                o oVar2 = dVar2.k;
                if (oVar2 != null) {
                    e4 = oVar2.e();
                } else {
                    dVar2.c.reset();
                    e4 = dVar2.c;
                }
                h2.transform(e4);
                this.a.addPath(h2);
                i++;
            }
        } else {
            this.a.set(mVar2.h());
        }
        this.c.op(this.a, this.b, op);
    }

    public void d(List<c> list, List<c> list2) {
        for (int i = 0; i < this.d.size(); i++) {
            ((m) this.d.get(i)).d(list, list2);
        }
    }

    public void e(ListIterator<c> listIterator) {
        while (listIterator.hasPrevious() && listIterator.previous() != this) {
        }
        while (listIterator.hasPrevious()) {
            c cVar = (c) listIterator.previous();
            if (cVar instanceof m) {
                this.d.add((m) cVar);
                listIterator.remove();
            }
        }
    }

    public Path h() {
        this.c.reset();
        h hVar = this.e;
        if (hVar.c) {
            return this.c;
        }
        int ordinal = hVar.b.ordinal();
        if (ordinal == 0) {
            for (ordinal = 0; ordinal < this.d.size(); ordinal++) {
                this.c.addPath(((m) this.d.get(ordinal)).h());
            }
        } else if (ordinal == 1) {
            c(Op.UNION);
        } else if (ordinal == 2) {
            c(Op.REVERSE_DIFFERENCE);
        } else if (ordinal == 3) {
            c(Op.INTERSECT);
        } else if (ordinal == 4) {
            c(Op.XOR);
        }
        return this.c;
    }
}
